@echo off

@rem enable delay expansion
setlocal ENABLEDELAYEDEXPANSION
if ERRORLEVEL 1 (
    echo Unable to enable DELAYED EXPANSION
    goto end
)

@rem set work dirs
SET CUR_DIR=%CD%
SET WORK_DIR=%~dp0..
CD /d "%WORK_DIR%"

set LOCALCLASSPATH=.
for /f "delims=" %%i in ('dir /b /a-d /od /s "%WORK_DIR%\lib\*.jar"') do set LOCALCLASSPATH=!LOCALCLASSPATH!;%%i

if not "%*"=="" (
  set JAVA_PARAMETERS=%*
) else (
  echo ERROR: Please specify the main class as Java parameters
  goto END
)

echo Starting: %JAVA_PARAMETERS%
java -cp "%LOCALCLASSPATH%" %JAVA_PARAMETERS%

:END
CD /d "%CUR_DIR%"
